package com.party.core.model.logistics;

import com.google.common.collect.Maps;

import java.util.Map;

/**
 * 物流业务类型枚举
 * Created by yifeng
 *
 * @date 2018/4/23 0023
 * @time 下午 16:19
 */
public enum WlTargetType {
    MALL(1, "商城"),

    GIFT(2, "礼包");

    WlTargetType(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    private Integer code;

    private String name;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    /**
     * 根据状态码获取状态值
     *
     * @param code 状态码
     * @return 状态值
     */
    public static String getValue(Integer code) {
        for (WlTargetType wlTargetType : WlTargetType.values()) {
            if (wlTargetType.getCode().equals(code)) {
                return wlTargetType.getName();
            }
        }
        return null;
    }

    /**
     * 枚举类型转换为map
     *
     * @return 转换后的map
     */
    public static Map<Integer, String> convertMap() {
        Map<Integer, String> map = Maps.newHashMap();
        for (WlTargetType wlTargetType : WlTargetType.values()) {
            map.put(wlTargetType.getCode(), wlTargetType.getName());
        }
        return map;
    }
}
